package cmd

import (
	"github.com/spf13/cobra"
	global2 "longmen/server/config/global"
	"longmen/server/internal/services/nami/api/v5/sports/basketball"
	"longmen/server/internal/services/nami/api/v5/sports/football"
	"longmen/server/internal/services/nami/config"
)

var recentCli = &cobra.Command{
	Use:   "recent",
	Short: "同步变更的赛程",
	Long:  "同步变更的赛程",
	Run: func(cmd *cobra.Command, args []string) {

		f := football.Football{}
		ball := basketball.BasketBall{}

		crontab.AddFunc("@every 1s", f.SyncRecent)
		crontab.AddFunc("@every 1s", ball.SyncRecent)
		crontab.Start()
		select {}
	},
	PreRun: func(cmd *cobra.Command, args []string) {
		global2.Initialize(configFile)
		config.InitConfig()
		err := global2.InitElasticSearch()
		if err != nil {
			global2.Log.Fatalf("%s", err.Error())
		}
	},
	PostRun: func(cmd *cobra.Command, args []string) {

	},
}
